package cn.monkey.io.transport.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import reactor.core.publisher.Sinks;

import java.util.function.Consumer;

public final class LastMessageChannelInboundHandler extends ChannelInboundHandlerAdapter {

    private final Consumer<Object> msgSubscriber;

    public LastMessageChannelInboundHandler(Consumer<Object> msgSubscriber) {
        this.msgSubscriber = msgSubscriber;
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        this.msgSubscriber.accept(msg);
    }
}
